﻿Public Class frmCustomerList
    Dim dbBase As New dbCustomer
    Dim frmCtrl As New FormControl
    Dim dsBase As DataSet
    Dim EntryID As String

    Private Sub frmCustomerList_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.WindowState = FormWindowState.Maximized
        EntryID = ""
        GridAndFind1.Enabled = True
        dsBase = dbBase.GetCustomerList()
        ToolbarHeader1.Iniliaze("LIST : Customer", Me, Nothing, GridAndFind1.getDataGridView(), "Code")
        GridAndFind1.Initialize(dsBase, "Code", ToolbarHeader1, Me, True)
        If (dsBase IsNot Nothing) Then
            'GridAndFind1.getDataGridView().Columns("Notes").AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill
            'GridAndFind1.getDataGridView().Columns("Journal Date").DefaultCellStyle.Format = "dd MMM yyyy"
            'GridAndFind1.getDataGridView().Columns("Debet").DefaultCellStyle.FormatProvider = System.Globalization.CultureInfo.CreateSpecificCulture("en-US")
            'GridAndFind1.getDataGridView().Columns("Debet").DefaultCellStyle.Format = "N2"
            'GridAndFind1.getDataGridView().Columns("Debet").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
            'GridAndFind1.getDataGridView().Columns("Credit").DefaultCellStyle.FormatProvider = System.Globalization.CultureInfo.CreateSpecificCulture("en-US")
            'GridAndFind1.getDataGridView().Columns("Credit").DefaultCellStyle.Format = "N2"
            'GridAndFind1.getDataGridView().Columns("Credit").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
        End If
        ToolbarHeader1.ActionCtrl(True, True, False, False, True, False, False, True, True)
    End Sub

    Private Sub tsNew_Click(ByVal sender As Object) Handles ToolbarHeader1.tsNewClick
        Dim OpenForm As New frmCustomerEntry
        OpenForm.EntryID = ""
        frmCtrl.OpenFormDetail(Me, OpenForm)
    End Sub

    Private Sub GridCellEnter_Click(ByVal sender As GridAndFind, KeyValue As String) Handles GridAndFind1.GridCellEnter
        Dim dvFind As DataView = New DataView(dsBase.Tables(0))
        dvFind.RowFilter = "[Code] = '" & KeyValue & "'"
        EntryID = dvFind.Item(0).Row("Code").ToString()
    End Sub

    Private Sub GridDoubleClick_Click(ByVal sender As GridAndFind) Handles GridAndFind1.GridDoubleClick
        Dim OpenForm As New frmCustomerEntry
        OpenForm.EntryID = EntryID
        frmCtrl.OpenFormDetail(Me, OpenForm)
    End Sub

    Private Sub tsView_Click(ByVal sender As Object) Handles ToolbarHeader1.tsViewClick
        Dim OpenForm As New frmCustomerEntry
        OpenForm.EntryID = EntryID
        frmCtrl.OpenFormDetail(Me, OpenForm)
    End Sub

    Private Sub tsPrint_Click(ByVal sender As Object) Handles ToolbarHeader1.tsPrintClick
        ''Event 
    End Sub

    Private Sub tsRefresh_Click(ByVal sender As Object) Handles ToolbarHeader1.tsRefreshClick
        frmCtrl.openChild(New frmCustomerList, Me.ParentForm)
    End Sub
End Class